package com.jy.admin.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.StringUtils;
import com.jy.admin.db.dao.PendingLogDao;
import com.jy.admin.db.entity.PendingLogEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: yujianfu
* Date: 2022-02-17
* Time: 11:22:52.111
*/

@Repository
public class PendingLogDaoImpl extends AbstractBaseMapper<PendingLogEntity> implements PendingLogDao {

    @Override
    public List<PendingLogEntity> searchList(String date, String orderNo, Integer status, String productName) {
        Map<String, Object> params = new HashMap<>();
        params.put("date", date);
        params.put("productName", productName);
        if (!StringUtils.isEmpty(orderNo)) {
            params.put("orderNo", "%" + orderNo + "%");
        } else {
            params.put("orderNo", null);
        }


        params.put("status", status);
        return getSqlSession().selectList(this.getStatement("searchList"), params);
    }

    @Override
    public PendingLogEntity selectById(Integer id) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", id);
        return getSqlSession().selectOne(this.getStatement("selectById"), params);
    }

    @Override
    public List<PendingLogEntity> getListByRobotIdAndStatus(String robotId, Integer status) {
        Map<String, Object> params = new HashMap<>();
        params.put("robotId", robotId);
        params.put("status", status);
        return getSqlSession().selectList(this.getStatement("getListByRobotIdAndStatus"), params);
    }

    @Override
    public PendingLogEntity selectByTelMsgId(String telMsgId) {
        Map<String, Object> params = new HashMap<>();
        params.put("telMsgId", telMsgId);
        return getSqlSession().selectOne(this.getStatement("selectByTelMsgId"), params);
    }
}